package com.lvandroid.play.bean;

import com.stx.xhb.xbanner.entity.BaseBannerInfo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 图片播放标签
 */
public class ImageItem extends PlayItem {
    //图片支持多张轮播，所以这里定义的是list
    public List<String> mImageSources = new ArrayList<>();

    public ImageItem() {
        super();
    }

    public List<String> getImageSources() {
        return mImageSources;
    }

    public void setImageSources(List<String> sources) {
        mImageSources.addAll(sources);
        this.mImageSources = sources;
    }

    public List<ImageInfo> createImageInfo() {
        List<ImageInfo> infos = new ArrayList<>();
        for (String s : mImageSources) {
            infos.add(new ImageInfo(s, s));
        }

        return infos;
    }

    @Override
    public String toString() {
        return "ImageItem{" +
                "mImageSources=" + Arrays.toString(mImageSources.toArray()) +
                ", name='" + name + '\'' +
                ", mWidth=" + mWidth +
                ", mHeight=" + mHeight +
                ", mDuration=" + mDuration +
                '}';
    }

    public static class ImageInfo implements BaseBannerInfo {
        public String mUrl;
        public String mTitle;

        public ImageInfo(String url, String title) {
            mUrl = url;
            mTitle = title;
        }

        @Override
        public String getXBannerUrl() {
            return mUrl;
        }

        @Override
        public String getXBannerTitle() {
            return mTitle;
        }
    }
}
